home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cxl41.arc / CXLDEMO.C < prev    next >
C/C++ Source or Header  |  1989-03-05  |  42KB  |  1,229 lines

  1. /*
  2.  
  3.         CXLDEMO.C  - A demonstration program for the CXL function library.
  4.  
  5.                     (c) 1987, 1988  by Mike Smedley
  6.  
  7. */
  8.  
  9.  
  10. #include    <bios.h>
  11. #include    <conio.h>
  12. #include    <dos.h>
  13. #include    <process.h>
  14. #include    <stdio.h>
  15. #include    <stdlib.h>
  16. #include    <string.h>
  17. #include    "cxldef.h"
  18. #include    "cxlkey.h"
  19. #include    "cxlmou.h"
  20. #include    "cxlstr.h"
  21. #include    "cxlvid.h"
  22. #include    "cxlwin.h"
  23.  
  24. #if     defined(__TURBOC__)                         /*  Turbo C  */
  25.     #include    <dir.h>
  26. #elif   defined(M_I86)  &&  !defined(__ZTC__)       /*  Microsoft C/QuickC  */
  27.     #include    <direct.h>
  28.     #define     bioskey(a)          _bios_keybrd(a)
  29.     #define     findfirst(a,b,c)    _dos_findfirst(a,c,b)
  30.     #define     findnext(a)         _dos_findnext(a)
  31.     #define     ffblk               find_t
  32.     #define     ff_name             name
  33. #elif   defined(__POWERC__)                         /*  Power C  */
  34.     #include    <direct.h>
  35. #endif
  36.  
  37. /*  function prototypes  */
  38.  
  39. void    activate_demo   (void);
  40. void    attr_bord_demo  (void);
  41. void    change_prompt   (void);
  42. int     check_date      (char *buf);
  43. void    copy_demo       (void);
  44. void    data_entry_demo (void);
  45. void    directory       (void);
  46. void    edit_help       (void);
  47. void    error_exit      (void);
  48. void    execute         (void);
  49. void    exit_prog       (void);
  50. void    hide_demo       (void);
  51. void    initialize      (void);
  52. void    line_inp_demo   (void);
  53. void    menu_demo       (void);
  54. void    move_demo       (void);
  55. void    opening_screen  (void);
  56. void    osshell         (void);
  57. void    pulldown_demo   (void);
  58. void    scrn_swap_demo  (void);
  59. void    scroll_demo     (void);
  60. void    str_select_demo (void);
  61. void    text_line_demo  (void);
  62. void    titl_resz_demo  (void);
  63. void    toggle_video    (void);
  64. void    update_clock    (void);
  65. void    wrap_up         (void);
  66.  
  67. /*  global variables  */
  68.  
  69. WINDOW  w[10];
  70. int     row,col,*sbuf1;                                    
  71. char    fname[9],minit[2],lname[18],address[35],phone[12],ssan[11],
  72.         city[16],state[3],zip[10],todate[8],password[13],balance[7];
  73. char    *spaces="           ",*pressakey="Press a key",*p;
  74.  
  75. /*---------------------------------------------------------------------------*/
  76.  
  77. /*  main function  */
  78.  
  79. void main(void)
  80. {
  81.     initialize();
  82.     for(;;) {
  83.         opening_screen();
  84.         scroll_demo();
  85.         attr_bord_demo();
  86.         titl_resz_demo();
  87.         data_entry_demo();
  88.         line_inp_demo();
  89.         menu_demo();
  90.         str_select_demo();
  91.         text_line_demo();
  92.         scrn_swap_demo();
  93.         activate_demo();
  94.         hide_demo();
  95.         move_demo();
  96.         copy_demo();
  97.         wrap_up();
  98.     }
  99. }
  100.  
  101. /*---------------------------------------------------------------------------*/
  102.  
  103. void activate_demo(void)
  104. {
  105.     register int i,j;
  106.  
  107.     /*  open demo window 6 and demonstrate activating of windows  */
  108.  
  109.     w[6]=wopen(10,48,23,77,1,LCYAN|_CYAN,LCYAN|_CYAN);
  110.     wtextattr(WHITE|_CYAN);
  111.     wputs("\n CXL's wactiv() is used to"
  112.           "\n activate a window, making"
  113.           "\n it available for windowing"
  114.           "\n operations.");
  115.     wprints(4,14,YELLOW|BLINK|_CYAN,pressakey);
  116.     if(waitkey()==ESC) exit_prog();
  117.     wprints(4,14,_CYAN,spaces);
  118.     for(i=0;i<=6;i++) {                      /*  activate windows 0 - 6  */
  119.         if(bioskey(1)) {                    /*  check for keypress      */
  120.             if(getch()==ESC) exit_prog();
  121.         }
  122.         wactiv(w[i]);
  123.         delay_(10);
  124.     }
  125.     w[7]=wopen(6,13,16,33,0,LCYAN,LCYAN|_BLUE);
  126.     if(!w[7]) error_exit();
  127.     w[8]=wopen(8,38,18,58,0,LMAGENTA,LMAGENTA|_RED);
  128.     if(!w[8]) error_exit();
  129.     for(i=0;i<300;i++) {
  130.         for(j=7;j<=8;j++) {
  131.             wactiv(w[j]);
  132.             wputs(j==7?"CXL  ":"DEMO  ");
  133.         }
  134.     }
  135.     wclose();
  136.     wclose();
  137. }
  138.  
  139. /*---------------------------------------------------------------------------*/
  140.  
  141. void attr_bord_demo(void)
  142. {
  143.     register int i;
  144.  
  145.     /*  open demo window 1 and demonstrate changing of
  146.         window attribute and changing of border style   */
  147.  
  148.     w[1]=wopen(10,35,23,65,0,YELLOW|_BLUE,YELLOW|_BLUE);
  149.     if(!w[1]) error_exit();
  150.     wtextattr(LCYAN|_BLUE);
  151.     wputs("\n  The wchgattr() function"
  152.           "\n  allows you to change the"
  153.           "\n  attribute of the active"
  154.           "\n  window.");
  155.     wcenters(6,YELLOW|BLINK|_BLUE,pressakey);
  156.     if(waitkey()==ESC) exit_prog();
  157.     wcenters(6,_BLUE,spaces);
  158.     wchgattr(LMAGENTA|_BLUE,WHITE|_GREEN);
  159.     delay_(12);
  160.     wchgattr(LGREEN|_LGREY,LMAGENTA|_RED);
  161.     delay_(12);
  162.     wchgattr(YELLOW|_BROWN,LCYAN|_BLUE);
  163.     if(bioskey(1)) {                            /*  check for keypress  */
  164.         if(getch()==ESC) exit_prog();
  165.     }
  166.     delay_(12);
  167.     wchgattr(YELLOW|_MAGENTA,YELLOW|_MAGENTA);
  168.     delay_(12);
  169.     wchgattr(LRED|_MAGENTA,WHITE|_MAGENTA);
  170.     delay_(12);
  171.     wtextattr(LGREEN|_MAGENTA);
  172.     wputs("\n\n  The wborder() function is"
  173.             "\n  used to change the style"
  174.             "\n  of the window's border.");
  175.     wcenters(10,YELLOW|BLINK|_MAGENTA,pressakey);
  176.     if(waitkey()==ESC) exit_prog();
  177.     wcenters(10,_MAGENTA,spaces);
  178.     for(i=1;i<=5;i++) {
  179.         delay_(18);
  180.         wborder(i);
  181.         if(bioskey(1)) {
  182.             if(getch()==ESC) exit_prog();
  183.         }
  184.     }
  185.     delay_(18);
  186.     wborder(0);
  187.     delay_(18);
  188. }
  189.  
  190. /*---------------------------------------------------------------------------*/
  191.  
  192. /*  this function is called in opening prompt.  changes colors of prompt  */
  193.  
  194. void change_prompt(void)
  195. {
  196.     static int i=LBLUE;
  197.  
  198.     wgotoxy(10,7);
  199.     setattr(i|_BLUE,23);
  200.     delay_(2);
  201.     i++;
  202.     if(i>WHITE) i=LBLUE;
  203. }
  204.  
  205. /*---------------------------------------------------------------------------*/
  206.  
  207. /*  this function validates the date field in the data entry window  */
  208.  
  209. int check_date(char *buf)
  210. {
  211.     int month,day;
  212.     char date[7];
  213.  
  214.     /*  parse date into numeric month and day  */
  215.  
  216.     if(!strblank(buf)) {
  217.         strcpy(date,buf);
  218.         *(date+4)='\0';
  219.         day=atoi(date+2);
  220.         *(date+2)='\0';
  221.         month=atoi(date);
  222.  
  223.         /*  validate numeric values  */
  224.  
  225.         if(month<1 || month>12) {
  226.             wperror("Invalid month");
  227.             return(1);
  228.         }
  229.         if(day<1 || day>31) {
  230.             wperror("Invalid day");
  231.             return(3);
  232.         }
  233.     }
  234.  
  235.     /*  return normally  */
  236.  
  237.     return(0);
  238. }
  239.  
  240. /*---------------------------------------------------------------------------*/
  241.  
  242. void copy_demo(void)
  243. {
  244.     /*  demonstrate making copies of the same window  */
  245.  
  246.     wtextattr(LRED|_BROWN);
  247.     wputs("\n\n The wcopy() function will"
  248.             "\n create a duplicate of the"
  249.             "\n active window.");
  250.     wprints(7,17,YELLOW|BLINK|_BROWN,pressakey);
  251.     if(waitkey()==ESC) exit_prog();
  252.     wprints(7,17,_BROWN,spaces);
  253.     w[8]=wcopy(0,0);
  254.     if(!w[8]) error_exit();
  255.     delay_(12);
  256.     w[9]=wcopy(1,37);
  257.     if(!w[9]) error_exit();
  258.     if(bioskey(1)) {                            /*  check for keypress  */
  259.         if(getch()==ESC) exit_prog();
  260.     }
  261.     delay_(18);
  262.     wclose();                                      /*  close copies  */
  263.     delay_(12);
  264.     wclose();
  265.     delay_(12);
  266. }
  267.  
  268. /*---------------------------------------------------------------------------*/
  269.  
  270. void data_entry_demo(void)
  271. {
  272.     register int i,mode;
  273.  
  274.     /*  open demo window 3 and demonstrate multi-field keyboard input  */
  275.  
  276.     w[3]=wopen(10,10,22,50,1,LCYAN|_BLUE,LCYAN|_BLUE);
  277.     if(!w[3]) error_exit();
  278.     wtextattr(LMAGENTA|_BLUE);
  279.     wputs("\n     The winpdef() and winpread()"
  280.           "\n     functions allow multi-field"
  281.           "\n     keyboard data entry.");
  282.     wcenters(5,YELLOW|BLINK|_BLUE,pressakey);
  283.     if(waitkey()==ESC) exit_prog();
  284.     wcenters(5,_BLUE,spaces);
  285.     setonkey(0x3b00,edit_help,0);     /* define F1 as help key */
  286.     for(mode=0;mode<=1;mode++) {
  287.         if(!wopen(5,5,22,60,3,LCYAN|_BLUE,LCYAN|_BLUE)) error_exit();
  288.         wtitle(mode?"[ Data Update Window ]":"[ Data Entry Window ]",
  289.             TLEFT,LCYAN|_BLUE);
  290.         wprints(1,2,WHITE|_BLUE,"First name?");
  291.         winpdef(1,15,fname,"MMMMMMMM",0,LGREEN|_LGREY,mode,NULL);
  292.         wprints(1,27,WHITE|_BLUE,"Initial?");
  293.         winpdef(1,37,minit,"U'.'",0,LGREEN|_LGREY,mode,NULL);
  294.         wprints(3,2,WHITE|_BLUE,"Last name?");
  295.         winpdef(3,15,lname,"MMMMMMMMMMMMAAAAA",0,LGREEN|_LGREY,mode,NULL);
  296.         wprints(5,2,WHITE|_BLUE,"Address?");
  297.         winpdef(5,15,address,"**********************************",'M',
  298.             LGREEN|_LGREY,mode,NULL);
  299.         wprints(7,2,WHITE|_BLUE,"City?");
  300.         winpdef(7,15,city,"MMMMMMMMMMMMMMM",0,LGREEN|_LGREY,mode,NULL);
  301.         wprints(7,35,WHITE|_BLUE,"State?");
  302.         winpdef(7,43,state,"UU",0,LGREEN|_LGREY,mode,NULL);
  303.         wprints(9,2,WHITE|_BLUE,"Zip Code?");
  304.         winpdef(9,15,zip,"#####'-'%%%%",0,LGREEN|_LGREY,mode,NULL);
  305.         wprints(9,29,WHITE|_BLUE,"Phone?");
  306.         winpdef(9,37,phone,"'('###') '###'-'####",0,LGREEN|_LGREY,mode,NULL);
  307.         wprints(11,2,WHITE|_BLUE,"Today's Date");
  308.         winpdef(11,15,todate,"<01>#'/'<0123>#'/'<89>#",0,LGREEN|_LGREY,mode,
  309.             check_date);
  310.         wprints(11,30,WHITE|_BLUE,"SSAN?");
  311.         winpdef(11,37,ssan,"<0123456>##'-'##'-'####",0,LGREEN|_LGREY,
  312.             mode,NULL);
  313.         wprints(13,2,WHITE|_BLUE,"Password?");
  314.         winpdef(13,15,password,"UUUUUUUUUUUU",'P',LGREEN|_LGREY,mode,NULL);
  315.         wprints(13,31,WHITE|_BLUE,"Balance?");
  316.         winpdef(13,41,balance,"'$'%%##'.'##",0,
  317.             LGREEN|_LGREY,mode,NULL);
  318.         wcenters(15,LBLUE|_BLUE,
  319.             ">>> Press F1 for Help with Editing Keys <<<");
  320.         wtextattr(WHITE|_LGREY);
  321.         setcursz(6,7);                      /*  turn cursor on  */
  322.         i=winpread();                       /*  read all defined fields  */
  323.         setcursz(32,0);                     /*  turn cursor back off  */
  324.         if(i) exit_prog();                  /*  check for Esc press  */
  325.         wclose();
  326.         if(!mode) {
  327.             wtextattr(LGREEN|_BLUE);
  328.             wprintf("\n\n     CXL's data entry functions"
  329.                       "\n     also allow you to update"
  330.                       "\n     data that already exists!");
  331.             wcenters(9,YELLOW|BLINK|_BLUE,pressakey);
  332.             if(waitkey()==ESC) exit_prog();
  333.             wcenters(9,YELLOW|BLINK|_BLUE,spaces);
  334.         }
  335.     }
  336.     setonkey(0x3b00,NULL,0);          /* undefine F1 as help key */
  337. }
  338.  
  339. /*---------------------------------------------------------------------------*/
  340.  
  341. /*  this is the 'Directory' function under the 'File' menu  */
  342.  
  343. void directory(void)
  344. {
  345. #if     !defined(__ZTC__)
  346.     char filespec[41],file1[13],file2[13];
  347.     int i,done,lines,files;
  348.     struct ffblk ffblk;
  349.  
  350.     strcpy(filespec,"*.*");
  351.     memset(filespec+3,' ',37);
  352.     filespec[40]='\0';
  353.     setcursz(6,7);
  354.     if(!wopen(4,14,20,59,0,LRED|_MAGENTA,LCYAN|_BLUE)) exit(1);
  355.     wtitle("[ Directory ]",TCENTER,LRED|_MAGENTA);
  356.     for(;;) {
  357.         if(!wopen(6,6,8,49,0,LMAGENTA|_RED,LMAGENTA|_RED)) exit(1);
  358.         wtitle("[ Filespec ]",TCENTER,LMAGENTA|_RED);
  359.         winpdef(0,1,filespec,"****************************************",'U',
  360.             BLUE|_LGREY,1,NULL);
  361.         wtextattr(WHITE|_LGREY);
  362.         i=winpread();
  363.         wclose();
  364.         if(i) break;
  365.         wclear();
  366.         wtextattr(LCYAN|_BLUE);
  367.         files=0;
  368.         lines=0;
  369.         done=findfirst(filespec,&ffblk,0);
  370.         for(;;) {
  371.             if(done) break;
  372.             files++;
  373.             strcpy(file1,ffblk.ff_name);
  374.             if(!done) done=findnext(&ffblk);
  375.             strcpy(file2,ffblk.ff_name);
  376.             if(done) {
  377.                 file2[0]='\0';
  378.             }
  379.             else {
  380.                 files++;
  381.                 done=findnext(&ffblk);
  382.             }
  383.             if(done) {
  384.                 ffblk.ff_name[0]='\0';
  385.             }
  386.             else {
  387.                 files++;
  388.             }
  389.             wprintf(" %-15s%-15s%s\n",file1,file2,ffblk.ff_name);
  390.             lines++;
  391.             if(lines>=14) {
  392.                 wtextattr(LGREEN|_BLUE);
  393.                 wprintf(" Press a key to continue....");
  394.                 wtextattr(LCYAN|_BLUE);
  395.                 i=waitkey();
  396.                 wprintf("\r");
  397.                 if(i==ESC) break;
  398.                 lines=0;
  399.             }
  400.             if(!done) done=findnext(&ffblk);
  401.         }
  402.         wtextattr(LGREEN|_BLUE);
  403.         wprintf(" Files found:  %d  Press a key....",files);
  404.         waitkey();
  405.     }
  406.     setcursz(32,0);
  407.     wclose();
  408. #endif
  409. }
  410.  
  411. /*---------------------------------------------------------------------------*/
  412.  
  413. /*  this function performs user requested help from data entry window  */
  414.  
  415. void edit_help(void)
  416. {
  417.     int wrow,wcol;
  418.  
  419.     wreadcur(&wrow,&wcol);
  420.     if(!wopen(0,13,24,66,1,YELLOW|_RED,YELLOW|_RED)) error_exit();
  421.     wtitle("[ Editing Keys ]",TCENTER,YELLOW|_RED);
  422.     wtextattr(WHITE|_RED);
  423.     wprints(1,3,WHITE|_RED,"LeftArrow       - previous position left");
  424.     wprints(2,3,WHITE|_RED,"RightArrow      - next position right");
  425.     wprints(3,3,WHITE|_RED,"UpArrow         - previous field up");
  426.     wprints(4,3,WHITE|_RED,"DownArrow       - next field down");
  427.     wprints(5,3,WHITE|_RED,"Ctrl-LeftArrow  - previous word left");
  428.     wprints(6,3,WHITE|_RED,"Ctrl-RightArrow - next word right");
  429.     wprints(7,3,WHITE|_RED,"Tab             - next field right");
  430.     wprints(8,3,WHITE|_RED,"Shift-Tab       - previous field left");
  431.     wprints(9,3,WHITE|_RED,"Enter           - process field");
  432.     wprints(10,3,WHITE|_RED,"Ctrl-Enter      - process all fields");
  433.     wprints(11,3,WHITE|_RED,"Home            - beginning of field");
  434.     wprints(12,3,WHITE|_RED,"End             - end of field");
  435.     wprints(13,3,WHITE|_RED,"Ctrl-Home       - beginning of 1st field");
  436.     wprints(14,3,WHITE|_RED,"Ctrl-End        - end of last field");
  437.     wprints(15,3,WHITE|_RED,"Ins             - insert character");
  438.     wprints(16,3,WHITE|_RED,"Del             - delete character");
  439.     wprints(17,3,WHITE|_RED,"BackSpace       - delete character left");
  440.     wprints(18,3,WHITE|_RED,"Ctrl-BackSpace  - delete word left");
  441.     wprints(19,3,WHITE|_RED,"Ctrl-T          - delete word right");
  442.     wprints(20,3,WHITE|_RED,"Ctrl-U          - delete to end of field");
  443.     wprints(21,3,WHITE|_RED,"Ctrl-Y          - delete to end of last field");
  444.     wprints(22,3,WHITE|_RED,"Esc             - abort data entry (and demo)");
  445.     setonkey(0x3b00,NULL,0);          /* undefine F1 as help key */
  446.     waitkey();
  447.     setonkey(0x3b00,edit_help,0);     /* redefine F1 as help key */
  448.     wclose();
  449.     wpgotoxy(wrow,wcol);
  450. }
  451.  
  452. /*---------------------------------------------------------------------------*/
  453.  
  454. /*  this function will be called if an error occurs  */
  455.  
  456. void error_exit(void)
  457. {
  458.     setcursz(6,7);                       /*  set cursor size back to normal  */
  459.     if(_werrno) {
  460.         printf("\nError:  %s      ",werrmsg());    /*  display error message */
  461.     }
  462.     else {
  463.         abort();
  464.     }
  465.     exit(1);
  466. }
  467.  
  468. /*---------------------------------------------------------------------------*/
  469.  
  470. /*  this is the 'Execute' function under the 'File' menu  */
  471.  
  472. void execute(void)
  473. {
  474.     char command[61];
  475.     int *sptr;
  476.  
  477.     setcursz(6,7);
  478.     if(!wopen(8,7,10,70,0,LMAGENTA|_RED,LMAGENTA|_RED)) exit(1);
  479.     wtitle("[ Execute DOS Command ]",TCENTER,LMAGENTA|_RED);
  480.     for(;;) {
  481.         winpdef(0,1,command,"****************************************"
  482.             "********************",0,BLUE|_LGREY,0,NULL);
  483.         wtextattr(WHITE|_LGREY);
  484.         if(winpread()) break;
  485.         sptr=ssave();
  486.         if(sptr==NULL) exit(1);
  487.         printf(" \b");
  488.         clrscrn();
  489.         system(command);
  490.         printf("\nPress any key to continue....");
  491.         waitkey();
  492.         srestore(sptr);
  493.     }
  494.     setcursz(32,0);
  495.     wclose();
  496. }
  497.  
  498. /*---------------------------------------------------------------------------*/
  499.  
  500. /*  this function will be called if Escape or Ctrl-C is pressed  */
  501.  
  502. void exit_prog(void)
  503. {
  504.     clearkeys();                       /*  clear keyboard buffer  */
  505.     setcursz(6,7);                     /*  set cursor size back to normal  */
  506.     srestore(sbuf1);                   /*  restore original screen  */
  507.     gotoxy_(row,col);                  /*  restore original cursor position  */
  508.     exit(0);
  509. }
  510.  
  511. /*---------------------------------------------------------------------------*/
  512.  
  513. /*  this function is a demo of the whide() and wunhide() functions  */
  514.  
  515. void hide_demo(void)
  516. {
  517.     register int i;
  518.  
  519.     wtextattr(LCYAN|_CYAN);
  520.     wputs("\n\n The whide() and wunhide()"
  521.             "\n functions are used to hide"
  522.             "\n and unhide windows.");
  523.     wcenters(10,YELLOW|BLINK|_CYAN,pressakey);
  524.     if(waitkey()==ESC) exit_prog();
  525.     wcenters(10,YELLOW|BLINK|_CYAN,spaces);
  526.     for(i=0;i<7;i++) {              /* hide all windows */
  527.         if(whide()) error_exit();
  528.         delay_(10);
  529.     }
  530.     for(i=0;i<7;i++) {              /* unhide most recently hidden first */
  531.         if(wunhide(_whrec->whandle)) error_exit();
  532.         delay_(10);
  533.     }
  534. }
  535.  
  536. /*---------------------------------------------------------------------------*/
  537.  
  538. /*  this function initializes the demo (save screen, cursor)  */
  539.  
  540. void initialize(void)
  541. {
  542.     readcur(&row,&col);             /*  save current cursor position  */
  543.     _dvcheck=1;                     /*  set to 0, no check for DESQview  */
  544.     _vbios=0;                       /*  set to 1, video writes using BIOS  */
  545.     videoinit();                    /*  initialize video  */
  546.     if(msinit()) msspeed(16,8);     /*  initialize mouse  */
  547.     setonkey(0x2e03,exit_prog,0);   /*  attach Ctrl-C to exit function  */
  548.     setonkey(0x6800,toggle_video,0);/*  attach Alt-F1 to toggle video  */
  549.     sbuf1=ssave();                  /*  save current screen contents  */
  550.     if(sbuf1==NULL) error_exit();
  551.     setcursz(32,0);                 /*  turn off cursor  */
  552. }
  553.  
  554. /*---------------------------------------------------------------------------*/
  555.  
  556. void line_inp_demo(void)
  557. {
  558.     int i;
  559.  
  560.     /*  open demo window 4 and demonstrate formatted line input  */
  561.  
  562.     w[4]=wopen(8,41,20,78,3,WHITE|_MAGENTA,WHITE|_MAGENTA);
  563.     if(!w[4]) error_exit();
  564.     wtextattr(LGREEN|_MAGENTA);
  565.     wputs("\n    For complete control of"
  566.           "\n    keyboard line input, there"
  567.           "\n    is the winputsf() function.");
  568.     wcenters(5,YELLOW|BLINK|_MAGENTA,pressakey);
  569.     if(waitkey()==ESC) exit_prog();
  570.     wcenters(5,YELLOW|_MAGENTA,spaces);
  571.     wtextattr(WHITE|_MAGENTA);
  572.     setcursz(6,7);                          /*  turn cursor on        */
  573.     i=winputsf(phone,"'\n\n  Phone Number?    '!R--!"
  574.         "'('!+!###!-!') '!+!###!-!'-'!+!####");
  575.     if(i) exit_prog();                      /*  check for Esc press   */
  576.     wtextattr(WHITE|_MAGENTA);
  577.     i=winputsf(ssan,"'\n\n  Soc Sec Number?  '!R-!"
  578.         "<0123456>##!-!'-'!+!##!-!'-'!+!####");
  579.     if(i) exit_prog();                      /*  check for Esc press   */
  580.     wtextattr(WHITE|_MAGENTA);
  581.     i=winputsf(todate,"\"\n\n  Today's Date?    \"!R-!"
  582.         "<01>#!-!'/'!+!<0123>#!-!'/'!+!'19'<89>#");
  583.     if(i) exit_prog();                      /*  check for Esc press   */
  584.     setcursz(32,0);                         /*  turn cursor back off  */
  585. }
  586.  
  587. /*---------------------------------------------------------------------------*/
  588.  
  589. void menu_demo(void)
  590. {
  591.     register int i;
  592.  
  593.     /*  clear window 4 and demonstrate pull-down & pop-up menus  */
  594.  
  595.     wclear();
  596.     wtextattr(LGREEN|_MAGENTA);
  597.     wputs("\n  With the wmenudef() & wmenuget()"
  598.           "\n  functions, you can make pull-down"
  599.           "\n  and pop-up menus.");
  600.     wcenters(5,YELLOW|BLINK|_MAGENTA,pressakey);
  601.     if(waitkey()==ESC) exit_prog();
  602.     pulldown_demo();
  603.     if(waitkey()==ESC) exit_prog();
  604.     wcenters(5,_MAGENTA,spaces);
  605.     if(!wopen(10,35,17,51,0,YELLOW|_BLACK,YELLOW|_BLACK)) error_exit();
  606.     wmenudef(0,0,LCYAN|_RED," Add record    ",'A',WHITE|_RED,NULL);
  607.     wmenudef(1,0,LCYAN|_RED," Show record   ",'S',WHITE|_RED,NULL);
  608.     wmenudef(2,0,LCYAN|_RED," Delete record ",'D',WHITE|_RED,NULL);
  609.     wmenudef(3,0,LCYAN|_RED," Update record ",'U',WHITE|_RED,NULL);
  610.     wmenudef(4,0,LCYAN|_RED," Print record  ",'P',WHITE|_RED,NULL);
  611.     wmenudef(5,0,LCYAN|_RED," Quit program  ",'Q',WHITE|_RED,NULL);
  612.     i=wmenuget(WHITE|_GREEN,'A',0);
  613.     if(!i) exit_prog();
  614.     wclose();
  615.     wtextattr(WHITE|_MAGENTA);
  616.     wgotoxy(5,9);
  617.     wprintf("You selected %c!",i);
  618.     delay_(18);
  619.     wgotoxy(5,9);
  620.     wputs("                ");
  621.     wprints(3,22,YELLOW|_MAGENTA,"Select one:");
  622.     wmenudef(5,3,LCYAN|_MAGENTA,"Add record",'A',LRED|_MAGENTA,NULL);
  623.     wmenudef(5,18,LCYAN|_MAGENTA,"Show record",'S',LRED|_MAGENTA,NULL);
  624.     wmenudef(7,3,LCYAN|_MAGENTA,"Delete record",'D',LRED|_MAGENTA,NULL);
  625.     wmenudef(7,18,LCYAN|_MAGENTA,"Update record",'U',LRED|_MAGENTA,NULL);
  626.     wmenudef(9,3,LCYAN|_MAGENTA,"Print record",'P',LRED|_MAGENTA,NULL);
  627.     wmenudef(9,18,LCYAN|_MAGENTA,"Quit program",'Q',LRED|_MAGENTA,NULL);
  628.     i=wmenuget(LCYAN|_LGREY,'A',0);
  629.     wprints(3,22,_MAGENTA,spaces);
  630.     if(!i) exit_prog();
  631.     delay_(10);
  632.     if(!wopen(7,15,10,65,0,YELLOW,LCYAN|_BLUE)) error_exit();
  633.     wmenudef(0,0,LMAGENTA|_BLUE,"Add",'A',WHITE|_BLUE,
  634.         "Create a new record");
  635.     wmenudef(0,8,LMAGENTA|_BLUE,"Delete",'D',WHITE|_BLUE,
  636.         "Delete an existing record");
  637.     wmenudef(0,19,LMAGENTA|_BLUE,"Print",'P',WHITE|_BLUE,
  638.         "Print hardcopy of existing record");
  639.     wmenudef(0,28,LMAGENTA|_BLUE,"Show",'S',WHITE|_BLUE,
  640.         "Display an existing record on screen");
  641.     wmenudef(0,36,LMAGENTA|_BLUE,"Update",'U',WHITE|_BLUE,
  642.         "Modify an existing record");
  643.     wmenudef(0,45,LMAGENTA|_BLUE,"Quit",'Q',WHITE|_BLUE,
  644.         "Quit program and return to DOS");
  645.     wtextattr(LGREEN|_BLUE);
  646.     if(!wmenuget(YELLOW|_LGREY,'A',0)) exit_prog();
  647.     delay_(18);
  648.     wclose();
  649. }
  650.  
  651. /*---------------------------------------------------------------------------*/
  652.  
  653. void move_demo(void)
  654. {
  655.     /*  open demo window 7 and demonstrate moving of active window  */
  656.  
  657.     w[7]=wopen(4,2,16,35,2,LGREEN|_BROWN,LGREEN|_BROWN);
  658.     if(!w[7]) error_exit();
  659.     wtextattr(WHITE|_BROWN);
  660.     wputs("\n  To move the active window,"
  661.           "\n  the wmove() function is"
  662.           "\n  used.");
  663.     wprints(3,9,YELLOW|BLINK|_BROWN,pressakey);
  664.     if(waitkey()==ESC) exit_prog();
  665.     wprints(3,9,_BROWN,spaces);
  666.     if(wmove(0,0)) error_exit();
  667.     delay_(12);
  668.     if(wmove(10,4)) error_exit();
  669.     delay_(12);
  670.     if(wmove(6,19)) error_exit();
  671.     delay_(12);
  672.     if(bioskey(1)) {                            /*  check for keypress  */
  673.         if(getch()==ESC) exit_prog();
  674.     }
  675.     if(wmove(1,13)) error_exit();
  676.     delay_(12);
  677.     if(wmove(2,35)) error_exit();
  678.     delay_(12);
  679.     if(wmove(11,35)) error_exit();
  680.     delay_(12);
  681. }
  682.  
  683. /*---------------------------------------------------------------------------*/
  684.  
  685. void opening_screen(void)
  686. {
  687.     register int i;
  688.  
  689.     /*  open up opening screen windows  */
  690.  
  691.     for(i=0;i<6;i++) {
  692.         w[i]=wopen(i,i+10,i+13,i+47,3,LCYAN|_BLUE,LCYAN|_BLUE);
  693.         if(!w[i]) error_exit();
  694.  
  695.         /*  sound tones of increasing pitch  */
  696.  
  697.         sound_(15000-((i+2)*1500),1);
  698.         sound_(12000-((i+1)*1500),1);
  699.     }
  700.  
  701.     wcenters(0,LRED," C X L ");
  702.     wcenters(1,LGREEN,"An Extended C Function Library");
  703.     wcenters(2,LGREEN,"Version 4.1");
  704.     wcenters(4,YELLOW,"by Mike Smedley");
  705.     wcenters(6,LMAGENTA,"(c) 1987, 1988 - All Rights Reserved");
  706.     wcenters(8,WHITE,"Demonstration Program");
  707.     wcenters(10,LCYAN|_BLUE,"Press any key to begin");
  708.  
  709.     /*  change colors of prompt until a key is pressed  */
  710.  
  711.     setkbloop(change_prompt);
  712.     if((getxch()&0x00ff)==ESC) exit_prog();
  713.     setkbloop(NULL);
  714.     wcenters(10,_BLUE,"                       ");
  715.  
  716.     /*  scroll the window's text up and out of the window  */
  717.  
  718.     for(i=0;i<10;i++) {
  719.         wscroll(1,SUP);
  720.         delay_(2);
  721.     }
  722.  
  723.     /*  close all open windows */
  724.  
  725.     for(i=5;i>=0;i--) {
  726.         wclose();
  727.         delay_(2);
  728.     }
  729. }
  730.  
  731. /*---------------------------------------------------------------------------*/
  732.  
  733. /*  this is the 'OS Shell' function under the 'File' menu  */
  734.  
  735. void osshell(void)
  736. {
  737.     int *sptr;
  738.  
  739.     setcursz(6,7);
  740.     sptr=ssave();
  741.     if(sptr==NULL) exit(1);
  742.     printf(" \b");
  743.     clrscrn();
  744.     printf("Type EXIT to return....\n");
  745.     system("COMMAND");
  746.     srestore(sptr);
  747.     setcursz(32,0);
  748. }
  749.  
  750. /*---------------------------------------------------------------------------*/
  751.  
  752. /*  This function is the demonstration of pull-down windows   */
  753.  
  754. void pulldown_demo(void)
  755. {
  756.     char m1;            /* return value from main menu */
  757.     char m2;            /* return value from a pull-down menu */
  758.  
  759.     if(!wopen(0,0,24,79,2,CYAN,CYAN)) error_exit();
  760.     setkbloop(update_clock);
  761.     wprints(0,0,_BLUE,"                                        "
  762.                       "                                      ");
  763.     wprints(1,0,CYAN,"────────────────────────────────────────"
  764.                       "──────────────────────────────────────");
  765.     wgotoxy(2,0);
  766.     wtextattr(YELLOW);
  767.     wputs("This is a sample editor interface to demonstrate how CXL's "
  768.           "wmenudef()\n"
  769.           "and wmenuget() functions can be used for pull-down menus.  "
  770.           "Use arrow keys\n"
  771.           "to move selection bar around and use the Esc key to back up ");
  772.     wputs("to the previous\n"
  773.           "menu.  Select 'Quit' from any menu to exit the pull-down demo.  "
  774.           "Try the\n"
  775.           "'Directory', 'Execute' and 'OS Shell' functions under the 'File' "
  776.           "menu.");
  777.     if(_mouse) {
  778.         wtextattr(WHITE);
  779.         wputs("\nSince you have a mouse, you can use it to move around and "
  780.               "select options!");
  781.     }
  782.  
  783.     /*  Initialize selection bar position to position 'F'.
  784.         The variable m1 is used for the load position of the main menu.
  785.         The variable m2 is used for how the main menu should act.
  786.         When an option is selected from the main menu, the selection will
  787.         be stored in m1 so that when the pull-down menu returns, the
  788.         selection bar will be positioned to the right position.
  789.         The pull-down menus will return their selection in variable m2.
  790.         If m1 == 0 then Escape was pressed from main menu or was set to 0 by
  791.         one of the pull-down menus.  Exit pull-down demo.               */
  792.  
  793.     m1='F';                         
  794.     m2=PDMAIN;
  795.     while(m1) {
  796.         wmenudef(0,2,YELLOW|_BLUE,"File",'F',LCYAN|_BLUE,NULL);
  797.         wmenudef(0,15,YELLOW|_BLUE,"Editing",'E',LCYAN|_BLUE,NULL);
  798.         wmenudef(0,31,YELLOW|_BLUE,"Defaults",'D',LCYAN|_BLUE,NULL);
  799.         wmenudef(0,47,YELLOW|_BLUE,"Help",'H',LCYAN|_BLUE,NULL);
  800.         wmenudef(0,59,YELLOW|_BLUE,"Options",'O',LCYAN|_BLUE,NULL);
  801.         if(wmenudef(0,73,YELLOW|_BLUE,"Quit",'Q',LCYAN|_BLUE,NULL))
  802.             error_exit();
  803.         m1=wmenuget(YELLOW|_MAGENTA,m1,m2);
  804.         switch(m1) {        /* test return value from main (horizontal) menu */
  805.             case 'F':
  806.  
  807.                 /* define pull-down menu for main menu option 'F' */
  808.  
  809.                 m2='L';
  810.                 if(!wopen(2,1,11,14,0,LGREY,LGREY)) error_exit();
  811.                 while(m2>PDMENU) {
  812.                     wmenudef(0,0,YELLOW|_BLUE," Load       ",'L',
  813.                         LCYAN|_BLUE,NULL);
  814.                     wmenudef(1,0,YELLOW|_BLUE," Save       ",'S',
  815.                         LCYAN|_BLUE,NULL);
  816.                     wmenudef(2,0,YELLOW|_BLUE," Rename     ",'R',
  817.                         LCYAN|_BLUE,NULL);
  818.                     wmenudef(3,0,YELLOW|_BLUE," New        ",'N',
  819.                         LCYAN|_BLUE,NULL);
  820.                     wmenudef(4,0,YELLOW|_BLUE," Directory  ",'D',
  821.                         LCYAN|_BLUE,NULL);
  822.                     wmenudef(5,0,YELLOW|_BLUE," Execute    ",'E',
  823.                         LCYAN|_BLUE,NULL);
  824.                     wmenudef(6,0,YELLOW|_BLUE," OS Shell   ",'O',
  825.                         LCYAN|_BLUE,NULL);
  826.                     if(wmenudef(7,0,YELLOW|_BLUE," Quit       ",'Q',
  827.                         LCYAN|_BLUE,NULL)) error_exit();
  828.                     m2=wmenuget(YELLOW|_MAGENTA,m2,PDMENU);
  829.                     switch(m2) {
  830.                         case 'D':
  831.                             directory();
  832.                             break;
  833.                         case 'E':
  834.                             execute();
  835.                             break;
  836.                         case 'O':
  837.                             osshell();
  838.                             break;
  839.                         case 'Q':
  840.                             m1=0;       /* needed to exit pull-down demo */
  841.                             m2=PDMAIN;
  842.                             break;
  843.                     }
  844.                 }
  845.                 wclose();
  846.                 break;
  847.             case 'E':
  848.  
  849.                 /* define pull-down menu for main menu option 'E' */
  850.  
  851.                 m2='C';
  852.                 if(!wopen(2,14,10,28,0,LGREY,LGREY)) error_exit();
  853.                 while(m2>PDMENU) {
  854.                     wmenudef(0,0,YELLOW|_BLUE," Cut         ",'C',
  855.                         LCYAN|_BLUE,NULL);
  856.                     wmenudef(1,0,YELLOW|_BLUE," Paste       ",'P',
  857.                         LCYAN|_BLUE,NULL);
  858.                     wmenudef(2,0,YELLOW|_BLUE," cOpy        ",'O',
  859.                         LCYAN|_BLUE,NULL);
  860.                     wmenudef(3,0,YELLOW|_BLUE," block Begin ",'B',
  861.                         LCYAN|_BLUE,NULL);
  862.                     wmenudef(4,0,YELLOW|_BLUE," block End   ",'E',
  863.                         LCYAN|_BLUE,NULL);
  864.                     wmenudef(5,0,YELLOW|_BLUE," Insert line ",'I',
  865.                         LCYAN|_BLUE,NULL);
  866.                     if(wmenudef(6,0,YELLOW|_BLUE," Delete line ",'D',
  867.                         LCYAN|_BLUE,NULL)) error_exit();
  868.                     m2=wmenuget(YELLOW|_MAGENTA,m2,PDMENU);
  869.                     /*  test m2 here  */
  870.                 }
  871.                 wclose();
  872.                 break;
  873.             case 'D':
  874.  
  875.                 /* define pull-down menu for main menu option 'D' */
  876.  
  877.                 m2='L';
  878.                 if(!wopen(2,30,11,52,0,LGREY,LGREY)) error_exit();
  879.                 while(m2>PDMENU) {
  880.                     wmenudef(0,0,YELLOW|_BLUE," Left margin       0 ",'L',
  881.                         LCYAN|_BLUE,NULL);
  882.                     wmenudef(1,0,YELLOW|_BLUE," Right margin     72 ",'R',
  883.                         LCYAN|_BLUE,NULL);
  884.                     wmenudef(2,0,YELLOW|_BLUE," Tab width         4 ",'T',
  885.                         LCYAN|_BLUE,NULL);
  886.                     wmenudef(3,0,YELLOW|_BLUE," tab eXpansion   yes ",'X',
  887.                         LCYAN|_BLUE,NULL);
  888.                     wmenudef(4,0,YELLOW|_BLUE," Insert mode     yes ",'I',
  889.                         LCYAN|_BLUE,NULL);
  890.                     wmenudef(5,0,YELLOW|_BLUE," iNdent mode     yes ",'N',
  891.                         LCYAN|_BLUE,NULL);
  892.                     wmenudef(6,0,YELLOW|_BLUE," Word wrap mode   no ",'W',
  893.                         LCYAN|_BLUE,NULL);
  894.                     if(wmenudef(7,0,YELLOW|_BLUE," Save defaults       ",'S',
  895.                         LCYAN|_BLUE,NULL)) error_exit();
  896.                     m2=wmenuget(YELLOW|_MAGENTA,m2,PDMENU);
  897.                     /*  test m2 here  */
  898.                 }
  899.                 wclose();
  900.                 break;
  901.             case 'H':
  902.  
  903.                 /* define pull-down menu for main menu option 'H' */
  904.  
  905.                 m2='H';
  906.                 if(!wopen(2,46,7,65,0,LGREY,LGREY)) error_exit();
  907.                 while(m2>PDMENU) {
  908.                     wmenudef(0,0,YELLOW|_BLUE," help on Help     ",'H',
  909.                         LCYAN|_BLUE,NULL);
  910.                     wmenudef(1,0,YELLOW|_BLUE," help on Editing  ",'E',
  911.                         LCYAN|_BLUE,NULL);
  912.                     wmenudef(2,0,YELLOW|_BLUE," help on Defaults ",'D',
  913.                         LCYAN|_BLUE,NULL);
  914.                     if(wmenudef(3,0,YELLOW|_BLUE," help on Options  ",'O',
  915.                         LCYAN|_BLUE,NULL)) error_exit();
  916.                     m2=wmenuget(YELLOW|_MAGENTA,m2,PDMENU);
  917.                     /*  test m2 here  */
  918.                 }
  919.                 wclose();
  920.                 break;
  921.             case 'O':
  922.  
  923.                 /* define pull-down menu for main menu option 'O' */
  924.  
  925.                 m2='Z';
  926.                 if(!wopen(2,56,8,77,0,LGREY,LGREY)) error_exit();
  927.                 while(m2>PDMENU) {
  928.                     wmenudef(0,0,YELLOW|_BLUE," screen siZe     43 ",'Z',
  929.                         LCYAN|_BLUE,NULL);
  930.                     wmenudef(1,0,YELLOW|_BLUE," Backup files   yes ",'B',
  931.                         LCYAN|_BLUE,NULL);
  932.                     wmenudef(2,0,YELLOW|_BLUE," bOxed display   no ",'O',
  933.                         LCYAN|_BLUE,NULL);
  934.                     wmenudef(3,0,YELLOW|_BLUE," Load options       ",'L',
  935.                         LCYAN|_BLUE,NULL);
  936.                     if(wmenudef(4,0,YELLOW|_BLUE," Save options       ",'S',
  937.                         LCYAN|_BLUE,NULL)) error_exit();
  938.                     m2=wmenuget(YELLOW|_MAGENTA,m2,PDMENU);
  939.                     /*  test m2 here  */
  940.                 }
  941.                 wclose();
  942.                 break;
  943.             case 'Q':
  944.  
  945.                 /* define pull-down menu for main menu option 'Q' */
  946.  
  947.                 m2='N';
  948.                 if(!wopen(2,60,7,78,0,LGREY,LGREY)) error_exit();
  949.                 while(m2>PDMENU) {
  950.                     wcclear(BLUE|_BLUE);
  951.                     wprints(0,2,WHITE|_BLUE,"Are you sure?");
  952.                     wmenudef(2,0,YELLOW|_BLUE,"       No        ",'N',
  953.                         LCYAN|_BLUE,NULL);
  954.                     if(wmenudef(3,0,YELLOW|_BLUE,"       Yes       ",'Y',
  955.                         LCYAN|_BLUE,NULL)) error_exit();
  956.                     m2=wmenuget(YELLOW|_MAGENTA,m2,PDMENU);
  957.                     switch(m2) {
  958.                         case 'N':
  959.                             m2=PDMAIN;
  960.                             break;
  961.                         case 'Y':
  962.                             m1=0;       /* needed to exit pull-down demo */
  963.                             m2=PDMAIN;
  964.                             break;
  965.                     }
  966.                 }
  967.                 wclose();
  968.                 break;
  969.         }
  970.     }
  971.     wclose();
  972.     setkbloop(NULL);
  973. }
  974.  
  975. /*---------------------------------------------------------------------------*/
  976.  
  977. void scrn_swap_demo(void)
  978. {
  979.     int *sbuf2;
  980.  
  981.     /*  open demo window 5 and demonstrate screen swapping  */
  982.  
  983.     w[5]=wopen(3,3,12,33,0,YELLOW|_BLACK,YELLOW|_BLACK);
  984.     if(!w[5]) error_exit();
  985.     wtextattr(LCYAN|_BLACK);
  986.     wputs("\n  The ssave() and srestore()"
  987.           "\n  functions allow screen"
  988.           "\n  swapping to/from memory.");
  989.     wcenters(5,LRED|BLINK|_BLACK,pressakey);
  990.     if(waitkey()==ESC) exit_prog();
  991.     wcenters(5,_BLACK,spaces);
  992.     sbuf2=ssave();
  993.     if(!sbuf2) error_exit();
  994.     gotoxy_(24,79);
  995.     clrscrn();
  996.     prints(10,27,LMAGENTA,"Press a key to return");
  997.     if(waitkey()==ESC) exit_prog();
  998.     srestore(sbuf2);
  999. }
  1000.  
  1001. /*---------------------------------------------------------------------------*/
  1002.  
  1003. void scroll_demo(void)
  1004. {
  1005.     register int i,j;
  1006.  
  1007.     /*  open demo window 0 and demonstrate text wraparound and
  1008.         scrolling from within a window                          */
  1009.  
  1010.     w[0]=wopen(1,1,11,41,2,LMAGENTA|_RED,LMAGENTA|_RED);
  1011.     if(!w[0]) error_exit();
  1012.     wtextattr(LCYAN|_RED);
  1013.     wprintf("\n CXL's window display functions like"
  1014.             "\n wprintf() & wputs() allow wrap-around"
  1015.             "\n and scrolling from within windows.");
  1016.     wcenters(7,YELLOW|BLINK|_RED,pressakey);
  1017.     if(waitkey()==ESC) exit_prog();
  1018.     wcenters(7,_RED,spaces);
  1019.     wgotoxy(8,0);
  1020.       for(i=0;i<15;i++) {
  1021.         if(bioskey(1)) {
  1022.             if(getch()==ESC) exit_prog();
  1023.             break;
  1024.         }
  1025.         for(j=DGREY;j<=WHITE;j++) {
  1026.             wtextattr(j|_RED);
  1027.             wputs("CXL   ");
  1028.             delay_(1);
  1029.         }
  1030.     }
  1031. }
  1032.  
  1033. /*---------------------------------------------------------------------------*/
  1034.  
  1035. void str_select_demo(void)
  1036. {
  1037.     char *p;
  1038.  
  1039.     /*  clear window 4 and demonstrate string selection  */
  1040.  
  1041.     wclear();
  1042.     wtextattr(LCYAN|_MAGENTA);
  1043.     wputs("\n  The wsseldef() and wsselget()    "
  1044.           "\n  functions allow you to select a  "
  1045.           "\n  string by using the arrow keys.");
  1046.     wcenters(5,YELLOW|BLINK|_MAGENTA,pressakey);
  1047.     if(waitkey()==ESC) exit_prog();
  1048.     wcenters(5,_MAGENTA,spaces);
  1049.     wgotoxy(6,1);
  1050.     wtextattr(LGREEN|_MAGENTA);
  1051.     wprintf("Select printer device:  ");
  1052.     wsseldef("PRN");
  1053.     wsseldef("LPT1");
  1054.     wsseldef("LPT2");
  1055.     wsseldef("COM1");
  1056.     wsseldef("COM2");
  1057.     wsseldef("COM3");
  1058.     wsseldef("COM4");
  1059.     setcursz(6,7);
  1060.     p=wsselget(YELLOW|_MAGENTA);
  1061.     setcursz(32,0);
  1062.     if(p==NULL) exit_prog();
  1063.     wtextattr(LRED|_MAGENTA);
  1064.     wprintf("\n\n You selected:  %s",p);
  1065.     delay_(18);
  1066. }
  1067.  
  1068. /*---------------------------------------------------------------------------*/
  1069.  
  1070. void text_line_demo(void)
  1071. {
  1072.     /*  clear window 4 and demonstrate text line drawing  */
  1073.  
  1074.     wclear();
  1075.     wsize(22,78);
  1076.     wtextattr(LGREEN|_MAGENTA);
  1077.     wputs("\n The whline() & wvline() functions"
  1078.           "\n are used for drawing \"smart\" text"
  1079.           "\n lines which will even make their "
  1080.           "\n own corners and intersections!   ");
  1081.     wcenters(6,YELLOW|BLINK|_MAGENTA,pressakey);
  1082.     if(waitkey()==ESC) exit_prog();
  1083.     wcenters(6,_MAGENTA,spaces);
  1084.     wtextattr(LCYAN|_MAGENTA);
  1085.     whline(6,6,24,3);
  1086.     delay_(18);
  1087.     wvline(6,6,4,3);
  1088.     delay_(18);
  1089.     whline(10,6,24,3);
  1090.     delay_(18);
  1091.     wtextattr(LBLUE|_MAGENTA);
  1092.     if(bioskey(1)) {                            /*  check for keypress  */
  1093.         if(getch()==ESC) exit_prog();
  1094.     }
  1095.     wvline(6,30,5,3);
  1096.     delay_(18);
  1097.     wvline(6,18,5,3);
  1098.     delay_(18);
  1099.     whline(7,6,25,3);
  1100.     delay_(18);
  1101.     wtextattr(LGREEN|_MAGENTA);
  1102.     if(bioskey(1)) {                            /*  check for keypress  */
  1103.         if(getch()==ESC) exit_prog();
  1104.     }
  1105.     whline(9,6,25,3);
  1106.     delay_(18);
  1107.     wvline(6,11,5,3);
  1108.     delay_(18);
  1109.     wvline(6,23,5,3);
  1110.     delay_(18);
  1111.     wtextattr(LMAGENTA|_MAGENTA);
  1112.     whline(8,6,25,3);
  1113.     delay_(18);
  1114. }
  1115.  
  1116. /*---------------------------------------------------------------------------*/
  1117.  
  1118. void titl_resz_demo(void)
  1119. {
  1120.     /*  open demo window 2 and demonstrate window titles
  1121.         and resizing of windows                           */
  1122.  
  1123.     w[2]=wopen(5,20,19,45,3,LCYAN|_GREEN,LCYAN|_GREEN);
  1124.     if(!w[2]) error_exit();
  1125.     wtextattr(WHITE|_GREEN);
  1126.     wputs("\n  The wtitle() function"
  1127.           "\n  allows you to give a"
  1128.           "\n  window a title.");
  1129.     wcenters(5,YELLOW|BLINK|_GREEN,pressakey);
  1130.     if(waitkey()==ESC) exit_prog();
  1131.     wcenters(5,_GREEN,spaces);
  1132.     wtitle("[ My Title ]",TLEFT,LCYAN|_GREEN);
  1133.     delay_(18);
  1134.     wtitle("[ My Title ]",TRIGHT,LCYAN|_GREEN);
  1135.     delay_(18);
  1136.     wtitle("[ My Title ]",TCENTER,LCYAN|_GREEN);
  1137.     wtextattr(LGREEN|_GREEN);
  1138.     wputs("\n\n\n  The wsize() function"
  1139.               "\n  allows you to resize"
  1140.               "\n  the active window.");
  1141.     wcenters(10,YELLOW|BLINK|_GREEN,pressakey);
  1142.     if(waitkey()==ESC) exit_prog();
  1143.     wcenters(10,_GREEN,spaces);
  1144.     wsize(19,60);
  1145.     delay_(12);;
  1146.     wsize(19,75);
  1147.     delay_(12);;
  1148.     wsize(24,75);
  1149.     delay_(12);;
  1150.     wsize(24,60);
  1151.     delay_(12);;
  1152.     wsize(24,45);
  1153.     delay_(12);;
  1154.     wsize(19,45);
  1155.     delay_(12);;
  1156. }
  1157.  
  1158. /*---------------------------------------------------------------------------*/
  1159.  
  1160. /*  this function toggles the video write method  */
  1161.  
  1162. void toggle_video(void)
  1163. {
  1164.     _vbios=_vbios?0:1;
  1165. }
  1166.  
  1167. /*---------------------------------------------------------------------------*/
  1168.  
  1169. /*  this function updates the on-screen clock in the pull-down demo  */
  1170.  
  1171. void update_clock(void)
  1172. {
  1173.     prints(0,70,LGREEN,systime(1));
  1174. }
  1175.  
  1176. /*---------------------------------------------------------------------------*/
  1177.  
  1178. void wrap_up(void)
  1179. {
  1180.     int ch;
  1181.  
  1182.     /*  close all windows except window 0  */
  1183.  
  1184.     while(_wtotal>1) {
  1185.         if(bioskey(1)) {
  1186.             if(getch()==ESC) exit_prog();
  1187.         }
  1188.         wclose();
  1189.         delay_(6);
  1190.     }
  1191.  
  1192.  
  1193.     /*  list other features of CXL  */
  1194.  
  1195.     wclear();
  1196.     wputs("  Other features of CXL include:\n");
  1197.     wtextattr(LGREEN|_RED);
  1198.     wputs("\n  - EGA 43 & VGA 50 line modes"
  1199.           "\n  - expanded memory usage"
  1200.           "\n  - screen/window swapping to disk"
  1201.           "\n  - advanced string manipulation");
  1202.     wputs("\n  - equipment detection"
  1203.           "\n  - mouse functions"
  1204.           "\n  - printer functions");
  1205.     wprints(8,26,YELLOW|BLINK|_RED,pressakey);
  1206.     if(waitkey()==ESC) exit_prog();
  1207.     wprints(8,26,_RED,spaces);
  1208.  
  1209.     /*  get response from the keyboard, controlling input  */
  1210.  
  1211.     wclear();
  1212.     if(wmove(7,19)) error_exit();
  1213.     wgotoxy(3,11);
  1214.     wtextattr(WHITE|_RED);
  1215.     wputs("View demo again?  ");
  1216.     setcursz(7,1);                           /*  turn cursor on  */
  1217.     clearkeys();                             /*  clear keyboard buffer  */
  1218.     ch=wgetchf("YyNn",'Y');                  /*  get keyboard response  */
  1219.     setcursz(32,0);                          /*  turn cursor back off  */
  1220.     if(ch==ESC) exit_prog();                 /*  see if Esc was pressed  */
  1221.     wclose();
  1222.     if(ch=='Y'||ch=='y') {
  1223.     }
  1224.     else {
  1225.         exit_prog();
  1226.     }
  1227. }
  1228.  
  1229.